<template>
	<view>
		<view class="header">
			<view class="header_text" >
				<view ><span class="meeting_name" style="font-size: 40rpx;">{{meeting.meetingName}}</span></view>
				<view style="font-size: 30rpx;">容纳人数：{{meeting.people}}</view>
				<view style="font-size: 30rpx;">位置：{{meeting.building}}号楼 {{meeting.room}}</view>
			</view>
		</view>
		<view>
			
			<view  class="info" style="margin-top: 30rpx;">
				<view class="left">
					<view style="color: #2979FF;margin-bottom: 20rpx;">会议室详细信息</view>
					<view style="display: flex;flex-direction: column;">
						<span style="border-bottom: 1px solid #DDDDDD;width: 300rpx;margin: 10rpx;">会议室id:{{this.meeting.id}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">会议室名称:{{this.meeting.meetingName}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">房间号:{{this.meeting.room}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">楼栋:{{this.meeting.building}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">可容纳人数:{{this.meeting.people}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">描述:{{this.meeting.description}}</span>
						<span style="border-bottom: 1px solid #DDDDDD;margin: 10rpx;">创建时间:<br/>{{this.meeting.createTime}}</span>
					</view>
				</view>
				<view class="right" >
					<span style="color: #2979FF;">选择类别:</span>
					<view style="margin: 130rpx;">
						<view style="margin: 20rpx 0;height: 50rpx;border-radius: 10rpx;background-color: #DDDDDD;">
							<span @click="handleUnReserved">未审核</span>
						</view>
						<view style="margin: 20rpx 0;height: 50rpx;border-radius: 10rpx;background-color: #b3ffd3;">
							<span @click="handleCommited">已通过</span>
						</view>
						<view style="margin: 20rpx 0;height: 50rpx;border-radius: 10rpx;background-color: #ffad92;">
							<span @click="handleUnCommited">未通过</span>
						</view>
					</view>
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				box1:false,
				meeting:'',
				subject:'',
				time:''
			}
		},
		onLoad(options) {
			this.meeting = JSON.parse(decodeURIComponent(options.meeting))
		},
		methods: {
			handleUnCommited(){
				uni.request({
					url:'/api/meeting/getMeetingInfoById?meetingId='+this.meeting.id,
					method:'get',
					success: (res) => {
						if(res.data.code===200&&res.data.data!=null){
							let list = res.data.data.reserveEntityList
							let lists = list.filter(item=>
								item.status===2
							
							)
							uni.navigateTo({
								url:"../unReserved/unReserved?data="+encodeURIComponent(JSON.stringify(lists))
							})
						}else{
							uni.showToast({
											icon: 'error',
											position: 'bottom',
											title: '未查询到信息！'+error
										})
						}
					},
					fail: (error) => {
						uni.showToast({
										icon: 'error',
										position: 'bottom',
										title: '未查询到信息！'+error
									})
					}
				})
			},
			handleCommited(){
				uni.request({
					url:'/api/meeting/getMeetingInfoById?meetingId='+this.meeting.id,
					method:'get',
					success: (res) => {
						if(res.data.code===200&&res.data.data!=null){
							let list = res.data.data.reserveEntityList
							let lists = list.filter(item=>
								item.status===1
							)
							
							uni.navigateTo({
								url:"../unReserved/unReserved?data="+encodeURIComponent(JSON.stringify(lists))
							})
						}else{
							uni.showToast({
											icon: 'error',
											position: 'bottom',
											title: '未查询到信息！'+error
										})
						}
					},
					fail: (error) => {
						uni.showToast({
										icon: 'error',
										position: 'bottom',
										title: '未查询到信息！'+error
									})
					}
				})
			},
			handleUnReserved(){
				uni.request({
					url:'/api/meeting/getMeetingInfoById?meetingId='+this.meeting.id,
					method:'get',
					success: (res) => {
						if(res.data.code===200&&res.data.data!=null){
							let list = res.data.data.reserveEntityList
							let lists = list.filter(item=>
								item.status===0
							)
							uni.navigateTo({
								url:"../unReserved/unReserved?data="+encodeURIComponent(JSON.stringify(lists))
							})
						}else{
							uni.showToast({
											icon: 'error',
											position: 'bottom',
											title: '未查询到信息！'+error
										})
						}
					},
					fail: (error) => {
						uni.showToast({
										icon: 'error',
										position: 'bottom',
										title: '未查询到信息！'+error
									})
					}
				})
			},
			handleReserve(){
				let data = {
				        meetingId: this.meeting.id,
				        subject: this.subject,
				        reserveTime: this.time.reserveTime,
				        reserverBegin: this.time.reserveBegin,
				        reserverEnd: this.time.reserveEnd,
						applyId:this.$store.getters.userinfo.userId
				      }
				uni.request({
					url:'/api/reserve/insertReserveInfo',
					method:'post',
					header:{
					            'content-type':'application/x-www-form-urlencoded'
					        },
					data:data,
					success: () => {
						uni.navigateTo({
							url:"../success/success"
						})
					},
					fail: (error) => {
						uni.showToast({
										icon: 'error',
										position: 'bottom',
										title: '预约失败！'+error
									})
					}
				})
			},
			getMeetingInfo(id){
				uni.request({
					url:'/api/meeting/getMeetingById?meetingId='+id,
					method:'get',
					success: (res) => {
						this.meeting = res.data.data
						console.log(res)
					}
				})
			}
			
		}
	}
</script>

<style>
	.tag{
		height: 100rpx;
		font-size: 33rpx;
		display: flex;
		margin: 10rpx;
		background-color: #ffaa7f;
		border-radius: 10rpx;
		align-items: center;
		justify-content: center;
	}
	.tag span{
		margin: 150rpx;
	}

	.info{
		font-size: 38rpx;
		display: flex;
		flex-direction: row;
	}
	.left{
		display: flex;
		flex-direction: column;
		height: 500rpx;
	}
	.right{
		height: 500rpx;
	}
	.right_item{
		border: 1px solid #dddddd;
		background-color: #53C21D;
		border-radius: 10rpx;
	}
.header{
	margin: 0;
	display: flex;
	flex-direction: column;
	height: 300rpx;
	background-color: #2979FF;
}
.header .header_text{
	font-size: 10rpx;
	margin-top:130rpx;
	margin-left: 50rpx;
	margin-right: 50rpx;
	height: 130rpx;
	border-radius: 10rpx;
	padding: 10rpx;
	background-color: white;
}

.meeting_name{
	
	margin-right: 380rpx;
}
.reserve{
	background-color: #aaff00;
	border-radius: 10rpx;
	margin-top: 1rpx;
	padding: 4rpx;
}
</style>
